/**
 * 
 */
var mode = "${mode}";
if(mode = "modify"){
	document.title="Register"?"Modify":"Register";
	if ( $("#property fieldset legend h4").eq(0).text() == "Register" ){
		$("#property fieldset legend h4").eq(0).text("Modify");
	}
	if( $("form").eq(0).attr("action") == "user/register.do" ){
		$("form").eq(0).attr("action", "user/modify.do");
	} 
}
//document.getElementByTag('form').submit()
function getParam(name){
//	console.log(name);
	var dom = document.getElementsByName(name)[0];
	return dom.value;
}
function makeParam(args){
	var params = "";
	for(index in args){
		arg = args[index];
//		console.log(arg);
		params+=(arg+"="+getParam(arg)+"&");		
	}
//	console.log(params.slice(0,-2));
//	return "name="+getParam("name")+"&base_duration="+getParam("base_duration")+"&base_cost="+getParam("base_cost")+"&unit_cost="+getParam("unit_cost")+"&descr="+getParam("descr")+"&cost_type="+getParam("cost_type");
	return params.slice(0,-2);
}
//action="user/register.do"
//$("input[type='button']").eq(1).bind("click", function(){
$("#submit").bind("click", function(){
//	$("form").eq(0)[0].submit();
	var _data = makeParam(["username", "password", "gender", "bornDate"]);
	$.ajax({
		url:"user/register.do",
		type:"POST",
//		'contentType' : 'application/json',
//		data:JSON.parse(_data),
		data:_data,
		'dataType' : 'json',
		'success' : function(jsonData){
			console.info(jsonData);
		},
	});
});